package Population;



public class Cell {
	public int x;
	public int y;
	public boolean isAlive;
	
	public Cell(int x_pos, int y_pos, boolean life)
	{
		x = x_pos;
		y = y_pos;
		isAlive = life;
	}
	
	public void Die()
	{
		isAlive = false;
	}
	
	public void Born()
	{
		isAlive = true;
	}
	
	public int FindFriends(Cell[][] world){
		int friends = 0;
		for (int i = x-1; i <= x+1; i++)
		{
			for (int j = y-1; j <= y+1; j++)
			{
				if(i>=0 && j>=0)
				{
					if(i<world[0].length && j<world.length)
					{
						if(world[j][i].isAlive)
						{
							if(i==x && j==y)
							{
								
							}
							else{friends++;}
						}
						else{}
					}
					else{}
				}
				else{}
			}
		}
		return friends;
	}
}
